package com.example.ideaexithoot;

import com.intellij.openapi.options.Configurable;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.Nullable;

import javax.swing.*;

public class AutoPushConfigurable implements Configurable {
    private AutoPushSettingsComponent component;

    @Override
    public @Nls(capitalization = Nls.Capitalization.Title) String getDisplayName() {
        return "AutoPush Settings";
    }

    @Override
    public @Nullable JComponent createComponent() {
        component = new AutoPushSettingsComponent();
        return component.getPanel();
    }

    @Override
    public boolean isModified() {
        AutoPushSettings settings = AutoPushSettings.getInstance();
        return !component.getAutopushPath().equals(settings.autopushPath);
    }

    @Override
    public void apply() {
        AutoPushSettings settings = AutoPushSettings.getInstance();
        settings.autopushPath = component.getAutopushPath();
    }

    @Override
    public void reset() {
        AutoPushSettings settings = AutoPushSettings.getInstance();
        component.setAutopushPath(settings.autopushPath);
    }

    @Override
    public void disposeUIResources() {
        component = null;
    }
}
